#ifndef CHATSERVICE_H
#define CHATSERVICE_H

#include <QObject>
//#include <QCoreApplication>
#include <QWebSocket>
#include <QUrl>
#include <QDebug>

class ChatService : public QObject
{
    Q_OBJECT
public:
    ChatService(QString id,QString identity);

    QString Id;
    QString Identity;

public slots:
    //初始化并发起请求
    void slot_initWebsocket();

    void slot_sendTextMsg(QString msg);//发送文本消息到服务器
    void slot_sendImageMsg(QByteArray imageMsg);//发送图片数据
    void onConnected();//成功连接到服务器时发送信号
    void onTextMessageReceived(const QString message);//接收到文本消息时
    //void onError(QAbstractSocket::SocketError error);//连接或通信过程中出现错误时
    void onDisconnected();//与服务器的连接断开时


private:
    QWebSocket *m_webSocket;

signals:
    void sig_Connected();

    void sig_TextMessageReceived(const QString message);



    void sig_Disconnected();

};

#endif // CHATSERVICE_H
